<template>
  <div>
    <p>
      <input
        type="text"
        name=""
        id=""
        v-model="username"
        placeholder="请输入用户名"
      />
    </p>
    <p>
      <input type="text" name="" id="" v-model="pwd" placeholder="请输入密码" />
    </p>
    <p>
      <button @click="loginFn">登录</button>
    </p>
  </div>
</template>

<script>
export default {
  name: "",
  props: [""],
  data() {
    return {
      username: "",
      pwd: "",
    };
  },
  methods: {
    loginFn() {
      if (this.username && this.pwd) {
        // 输入正确
        localStorage.setItem("username", this.username);
        // 跳转到首页
        this.$router.push("/");
      } else {
        alert("输入有误,重新输入");
      }
    },
  },
};
</script>
<style scoped>
</style>